define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'club/vipclub/index',
                    table: 'club',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                columns: [
                    [
                        {field: 'owner', title: __('Owner')},
                        {field: 'nickname', title: __('Nickname'), operate: false},
                        {field: 'name', title: __('Name'), operate: false},
                        {field: 'id', title: __('Id')},
                        {field: 'type', title: __('Type'), operate: false},
                        {field: 'usernum', title: __('Usernum'), operate: false},
                        {field: 'totalnum', title: __('Totalnum'), operate: false},
                        {field: 'totaldiamond', title: __('Totaldiamond'), operate: false},
                        {field: 'totalscore', title: __('Totalscore'), operate: false},
                        {field: 'todaynum', title: __('Todaynum'), operate: false},
                        {field: 'todayscore', title: __('Todayscore'), operate: false},
                        {field: 'diamond', title: __('Diamond'), operate: false},
                        {field: 'operate', title: __('管理'), table: table, events: Table.api.events.operate,
                            buttons: [
                                {name: 'detail', text: '成员列表', classname: 'btn btn-xs btn-info', url: 'club/vipuser/index'},
                                {name: 'userlog', text: '成员记录', classname: 'btn btn-xs btn-success', url: 'club/vipuserlog/index'}
                            ],
                            formatter: Table.api.formatter.operate
                        },
                    ]
                ],
                
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});